package com.power.sifa.correction.dao;

import com.power.sifa.correction.model.pojo.vo.RecordVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.correction.model.Cre_work;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 预警处置任务 持久层(hibernate)
 */

public interface Cre_workDao extends JpaRepository<Cre_work, Serializable>, JpaSpecificationExecutor<Cre_work>, Repository<Cre_work, Serializable>, Cre_workDaoCustom<Cre_work, Serializable> {

    @Modifying
    @Transactional
    @Query("delete  from Cre_work s where  s.id in (:ids) ")
    void removeByIds(@Param("ids") List<Integer> ids);


    /**
     * 更新预警处置任务状态
     *
     * @param id
     * @param worktype
     */
    @Modifying
    @Transactional
    @Query("update Cre_work s set s.worktype = :worktype where s.id = :id ")
    void updateWorktype(String id, Integer worktype);

    /**
     * 更新预警处置状态
     *
     * @param id
     * @param status
     */
    @Modifying
    @Transactional
    @Query("update Cre_work s set s.status = :status where s.id = :id ")
    void updateStatus(String id, Integer status);

    /**
     * 更新预警处置状态和办结时间
     *
     * @param id
     * @param status
     */
    @Modifying
    @Transactional
    @Query("update Cre_work s set s.status = :status, s.exectime = :exectime where s.id = :id ")
    void updateStatus(String id, Integer status, Date exectime);

    /**
     * 更新预警任务督办id
     *
     * @param id
     * @param supid
     */
    @Modifying
    @Transactional
    @Query("update Cre_work s set s.supid = :supid where s.id = :id ")
    void setSupid(String id, String supid);

    @Query("select c from Cre_work c where c.warnid = :warnId")
    Cre_work getByWarnId(String warnId);
}
